//
//  UIButton+HighlightStyle.m
//  QoilPublic
//
//  Created by 杨凯 on 16/7/20.
//  Copyright © 2016年 杨凯. All rights reserved.
//

#import "UIButton+HighlightStyle.h"

@implementation UIButton (HighlightStyle)

- (void)blueStyle{

    [self setBackgroundImage:[self buttonImageFromColor:[UIColor colorWithRed:38/255.0 green:120/255.0 blue:200/255.0 alpha:1]] forState:UIControlStateHighlighted];
    [self setTitleColor:[QColorUtility defaultDisGrayColor] forState:UIControlStateHighlighted];

}

- (UIImage *)buttonImageFromColor:(UIColor *)color {
    CGRect rect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}

- (void)whiteStyle{
    [self setBackgroundImage:[self buttonImageFromColor:[UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1]] forState:UIControlStateHighlighted];
    [self setTitleColor:[QColorUtility defaultDisGrayColor] forState:UIControlStateHighlighted];
}



@end
